<template>
	<view class="person_password">
		<view class="main">
			<view class="input">
				<view class="left">原密码</view>
				<view class="right">
					<u-input v-model="old_pass" type="password" :clearable='false' placeholder='请输入原密码' />
				</view>
			</view>
			<view class="input">
				<view class="left">新密码</view>
				<view class="right">
					<u-input v-model="new_pass" type="password" :clearable='false' placeholder='请输入新密码' />
				</view>
			</view>
			<view class="input">
				<view class="left">确认新密码</view>
				<view class="right">
					<u-input v-model="new_pass_two" type="password" :clearable='false' placeholder='请再次输入新密码' />
				</view>
			</view>
		<!-- 	<view class="input">
				<view class="left">用户ID</view>
				<view class="right">
					<u-input v-model="phone" type="number" :clearable='false' placeholder='请输入ID' />
				</view>
			</view> -->
		</view>
		<!-- <view class="tip">注：密码需包含字母和数字，8-16个字符</view> -->
		<!-- 底部 -->
		<BottomBtn title='保存' @submit='submitBtn'></BottomBtn>
	</view>
</template>

<script>
	import BottomBtn from '@/components/bottom_btn/bottom_btn.vue';
	export default {
		components:{
			BottomBtn
		},
		data() {
			return {
				old_pass:'',
				new_pass:'',
				new_pass_two:''
			};
		},
		methods:{
			// 底部按钮
			submitBtn(){
				var that = this
				if(that.old_pass==''){
					that.$tips.showToast('请输入原密码')
					return
				}else if(that.new_pass==''){
					that.$tips.showToast('请输入新密码')
					return
				}else if(that.new_pass_two==''){
					that.$tips.showToast('请再次输入密码')
					return
				}else if(that.new_pass!=that.new_pass_two){
					that.$tips.showToast('新密码不一致')
					return
				}else{
					that.$tips.showLoading('修改中')
					var params = {
						password:that.old_pass,
						newpassword:that.new_pass,
						newpassword_tow:that.new_pass_two,
					}
					that.$httpApi.userUppwd(params).then((res)=>{
						that.$tips.hideLoading()
						if(res.code==1){
							that.$tips.showToast('修改成功')
							setTimeout(function(){
								uni.reLaunch({
									url:'/pages/signIn/sign_in'
								})
							},2000)
						}
					})
				}
			},
		}
	}
</script>

<style lang="less">
	.person_password{
		width: 100%;
		padding-top: 24rpx;
		.main{
			width: 100%;
			padding: 20rpx 32rpx;
			background: #fff;
			.input{
				width: 100%;
				height: 100rpx;
				display: flex;
				align-items: center;
				.left{
					width: 200rpx;
					font-size: 28rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 500;
					color: #222222;
				}
				.right{
					width: calc(100% - 200rpx);
					display: flex;
					align-items: center;
					u-input{
						width: 100%;
						font-size: 28rpx;
						font-family: PingFang SC-Medium, PingFang SC;
						font-weight: 500;
						color: #222222;
					}
				}
			}
		}
		.tip{
			width: 100%;
			padding: 20rpx 32rpx;
			font-size: 24rpx;
			font-family: PingFang SC-Regular, PingFang SC;
			font-weight: 400;
			color: #666666;
		}
	}
</style>
